// ml:run = $bin < input
#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>

long long n;
long long cost;
std::deque<long long> dq;

bool judge(long long mid)
{
    auto q = dq;
    int first = ((n - 1) % (mid - 1)) + 1;
    if (!((n - 1) % (mid - 1))) first = mid;
    long long sum = 0;
    for (long long i = 0; i < first; i++) {
        if (q.empty()) break;
        auto now = q.front(); q.pop_front();
        sum += now;
    }
    q.push_back(sum);
    while (q.size() != 1) {
        long long tmp = 0;
        for (long long i = 0; i < mid; i++) {
            if (q.empty()) break;
            auto now = q.front(); q.pop_front();
            tmp += now;
        }
        q.push_back(tmp);
        sum += tmp;
    }
    return sum <= cost;
}

int main()
{
    std::ios_base::sync_with_stdio(false);
    long long T; std::cin >> T;
    while (T--) {
        std::cin >> n >> cost;
        std::vector<int> v(n);
        dq.clear();
        for (long long i = 0; i < n; i++)
            std::cin >> v[i];
        if (n <= 1) {
            std::cout << "0\n";
            continue;
        }
        std::sort(v.begin(), v.end());
        for (auto i : v) dq.push_back(i);
        long long l = 2, r = n;
        while (l + 1 < r) {
            long long mid = (l + r) / 2;
            if (judge(mid)) r = mid;
            else l = mid;
        }
        if (judge(l)) r = l;
        std::cout << r << "\n";
    }
}

